<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>

<head>
    <title>预览文章</title>
    <t:base type="jquery,easyui,tools,DatePicker,ckeditor"></t:base>
</head>
<style type="text/css">
    #container{position:absolute; top:5px; bottom:50px; left:0; right:0; overflow-y:auto}
    #bottomnav {position: absolute; bottom: 0px; left: 0; right: 0; height: 30px; line-height: 30px; text-align: center;}
    #bottomnav .btn {display: inline-block;padding: 0 20px;margin: 0 10px; margin-right: 8px; height: 30px;line-height: 30px;background: #1964a0;color: #fff;}
    #bottomnav .fr{ float: right;}
    #bottomnav .fl{ float: left;}

    #marquee p{margin:0}

</style>

<script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/AmazeUI/js/amazeui.min.js"></script>

<link rel="stylesheet" href="${webRoot}/plug-in/AmazeUI/css/amazeui.min.css"/>
<script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script language="javascript" src="http://qzs.qq.com/tencentvideo_v1/js/tvp/tvp.player.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/marquee/marquee.js"></script>
<script type="text/javascript">

    $(function(){
//        f_showArticleNotice();
    })

    function f_showArticleNotice(){
        $.ajax({
            url: "officialWhController.do?findArticleNotice",
            type: "post",
            dataType: "json",
            async: false,
            success: function(data){

                if(data.success){
                    $("#marquee").html(data.msg);
                }else{
                    $("#marquee").html(data.msg);
                }


            }
        });

    }

    function f_exeucNotice(){
        setTimeout(function(){
            f_showArticleNotice();
            new Marquee("marquee",0,2,790,40,100,4000,500)
        },500);
    }

</script>
<body  scroll="yes" style="position:absolute; top:0; bottom:0; left:0; right:0;"   >
<%--<div style="position:fixed; border:1px solid #dcdcdc; background:#fafadc; width:800px; height:50px; padding:5px;">--%>
    <%--<div id="marquee" style="overflow: hidden; height: 40px; width: 790px; line-height: 20px;">--%>

    <%--</div>--%>

    <%--<script defer>--%>
        <%--new Marquee("marquee",0,2,790,40,100,4000,500)--%>
    <%--</script>--%>
<%--</div>--%>


<%--</div>--%>
    <div id="container">
        <c:choose>
            <c:when test="${format == 13 and source == 105}">
                <div id="mod_player"></div>
                <script language="JavaScript">
                    var video = new tvp.VideoInfo();
                    //向视频对象传入视频vid
                    video.setVid("${path}");
                    var player = new tvp.Player(800, 500);
                    //设置播放器初始化时加载的视频
                    player.setCurVideo(video);
                    //输出播放器
                    player.write("mod_player");
                </script>
            </c:when>
            <c:when test="${format == 13}">
                <div id="otherPlayer">
                    <object width="950px" height="475px" data="${path}" type="application/x-shockwave-flash">
                        <!--<![endif]-->
                        <param value="high" name="quality">
                        <param value="opaque" name="wmode">
                        <param name="allowFullScreen" value="true">
                        <param value="6.0.65.0" name="swfversion ">
                        <!--[if !IE]>-->
                    </object>
                </div>
            </c:when>
            <c:when test="${format == 12}">
                <div class="am-slider am-slider-default" data-am-flexslider id="pics">
                    <ul class="am-slides">
                        <c:forEach var="pic" items="${pics}">
                            <li><img src="${pic.path}" style="max-width: 800px; max-height: 500px"/><div class="am-slider-desc">${pic.alt}</div></li>
                        </c:forEach>
                    </ul>
                </div>
            </c:when>
            <c:when test="${format == 11}">
                <div id="content">
                        ${content}
                </div>
            </c:when>
            <c:otherwise>
                <div>不支持该格式</div>
            </c:otherwise>
        </c:choose>
</div>
    <%-- //TODO 预览功能 暂时注释 --%>
    <div id="bottomnav">
        <%--<a class="btn no">审核</a><!--如果不需要操作就class里面就加上 no-->--%>
        <%--<a class="btn" href="javascript:f_showUpdate()">修改</a>--%>
        <%--<a class="btn" href="javascript:f_showPrevious()">上一篇</a>--%>
        <%--<a class="btn" href="javascript:f_showNextId()">下一篇</a>--%>
        <a class="btn fl" href="javascript:f_showUpdate()">修改</a>
        <span class="fr">
	        <a class="btn" href="javascript:f_showPrevious()">上一篇</a>
	        <a class="btn" href="javascript:f_showNextId()">下一篇</a>
        </span>
    </div>
<script type="text/javascript">


//    $(function(){
//        var islayer=$(window.parent.document).find("#ldg_lockmask").length;
//        if(islayer==0)
//        {
//            $(window.parent.document.body).append("<div id=\"ldg_lockmask\" style=\"position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; overflow: hidden; z-index: 1000;\"></div>");
//        }
//    });

    function f_showUpdate(){

        var fname=window.name;//frame 名字

        var isBoo = getWindow().f_optButton(fname,"修改");

        if(isBoo == false){
            alert("权限不够！");
        }



    }

    //关闭当前窗口
    function f_closeWindow(){

        frameElement.api.close();
    }

    function f_showPrevious(){

        var articleId = getWindow().f_getPreviousId();

        console.log(articleId)
        console.log(articleId == "")
        if(articleId == ""){
            alert("没有上一篇了");
            return;
        }

        $("html").load("officialWhController.do?getOfficialWh&articleId="+articleId);

        f_exeucNotice();
//        var xx = $(".ui_dialog iframe",parent.document).html();

//        var fname=window.name;
//        console.log($("iframe[name="+fname+"]",parent.document)[0]);
//        var iframe=parent.document.getElementsByName(fname)[0];
//
//
//        iframe.src="officialWhController.do?getOfficialWh&articleId="+articleId;

    }
    function f_showNextId() {

        var articleId = getWindow().f_getNextId();

        if (articleId == "") {
            alert("没有下一篇了");
            return;
        }

        $("html").load("officialWhController.do?getOfficialWh&articleId="+articleId);

        f_exeucNotice();

//        var fname=window.name;
//        var iframe=parent.document.getElementsByName(fname)[0];
//
//        iframe.src="officialWhController.do?getOfficialWh&articleId="+articleId;
    }

    //获取父窗口 Window对象
    function getWindow(){

        var win = null;

        //找到当前打开的父页面
        $("#maintabs .tabs li",parent.document).each(function(i){

            if($(this).attr("class") == "tabs-selected"){

                var tabs = $("#maintabs .tabs-panels-noborder",parent.document).find(".panel").get(i);

                var ife= $(tabs).find("iframe").get(0);

                var ifr = ife;
                win = ifr.window || ifr.contentWindow;

            }

        });

        return win;
    }

$(function(){
    var content = $("#content").html();
    if(content){
        content = content.replace(/src=".*?upload/g, 'src="${webRoot}/upload');
        $("#content").html(content);
    }
})
</script>
</body>
</html>